import React , {Component} from "react"
import SwipeReact from "../../components/swiper";
import src1 from "../../../assets/images/slide1.jpg"
import src2 from "../../../assets/images/slide2.jpg"
import src3 from "../../../assets/images/slide3.jpg"

export default class Guide extends Component{

    constructor(props){
        super(props);
        this.state = {
            imgList:[]
        }
    }
    // componentWillMount   时间差 
    componentDidMount(){
        this.setState({
            imgList: [src1,src2,src3]
        })
    }

    goto=(idx)=>{
        // 滑动最后一页跳转 app /首页 
        const {history} = this.props;
        history.push("/layout/index");
    }

    render(){
        var images 
        if(this.state.imgList.length>0){
            images = this.state.imgList.map((item,idx)=>{
                return (
                    <img onClick={()=>{this.goto(idx)}} src={item} key={idx} className="img" alt=""/>
                )
            })
        }
        return (
            <div className="section">
                <SwipeReact swiperOptions={{loop:false}} >
                    {images}
                </SwipeReact>
            </div>
        )
    }
}